package com.liuguang.testassert.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName: TestSecurityContriller
 * @Description：
 * @Author: wanghr
 * Date: 3:42 PM 2020/6/1
 * Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/security")
public class TestSecurityContriller {

    @RequestMapping("/test1")
    public String test1(HttpServletRequest request) {
        log.info("管理员才能进入方法了");
        String requestURI = request.getRequestURI();
        return "管理员进入方法了";
    }
    @RequestMapping("/test2")
    public String test2(HttpServletRequest request) {
        log.info("老板才能进入方法了");
        String requestURI = request.getRequestURI();
        return "老板进入方法了";
    }

    @RequestMapping("/loginsuccess")
    public String loginsuccess() {
        log.info("自定义登录界面，登录成功，跳转到该方法");
        return "自定义登录界面，登录成功，跳转到该方法";
    }
    @RequestMapping("/noanthentication")
    public String noanthentication(HttpServletRequest request) {
        log.info("不需验证登录就能进的方法");
        String requestURI = request.getRequestURI();
        return "不需验证登录就能进的方法";
    }
    @Secured("老认证了")
    @RequestMapping("/securited1")
    public String securited1(HttpServletRequest request) {
        log.info("进入授权获取方法");
        String requestURI = request.getRequestURI();
        return "进入授权获取方法";
    }
}
